/*
 * @lc app=leetcode.cn id=1736 lang=javascript
 *
 * [1736] 替换隐藏数字得到的最晚时间
 */

// @lc code=start
/**
 * @param {string} time
 * @return {string}
 */
var maximumTime = function (time) {
  const [hour, minute] = time.split(':');
  let [hfirst, hsecond] = hour.split('');
  hfirst = hfirst === '?' ? (hsecond === '?' || hsecond < '4' ? '2' : '1') : hfirst;
  hsecond = hsecond === '?' ? (hfirst === '2' ? '3' : '9') : hsecond;
  let [mfirst, msecond] = minute.split('');
  mfirst = mfirst === '?' ? '5' : mfirst;
  msecond = msecond === '?' ? '9' : msecond;
  console.log(`${hfirst}${hsecond}:${mfirst}${msecond}`);
  return `${hfirst}${hsecond}:${mfirst}${msecond}`;
};
// @lc code=end

maximumTime("?4:03");
